<?php
$form = $this->form;
$form->prepare();
$form->setAttribute('action', $this->url('user/login'));
$form->setAttribute('method', 'post');
?>
<div id="content">
    <div class="row">
        <?php if(count($flashMessages)) {
            foreach ($flashMessages as $msg) { ?>
                <div class="alert alert-block alert-success">
                    <a class="close" data-dismiss="alert" href="#">×</a>
                    <p><?php echo $this->translate($msg) ?></p>
                </div>
            <?php }
        } ?>

        <div class="col-sm-4 col-sm-offset-0 col-md-12 col-md-offset-0">
            <span class="text-center">
            </span>
            <div class="panel panel-default">
                <div class="panel-heading">
                    <h3 class="panel-title">
                        Login
                    </h3>
                    <?php if ($this->enableRegistration) : ?>
                    <div class="text-right">
                        <?php echo $this->translate('Not registered?'); ?>
                        <a href="<?php echo $this->url('user/register') . ($this->redirect ? '?redirect='.$this->redirect : '') ?>">
                            <?php echo $this->translate('Sign up!'); ?>
                        </a>
                    </div>
                    <?php endif; ?>
                </div>
                <div class="panel-body">
                    <?php echo $this->form()->openTag($form); ?>
                        <div class="form-group col-xs-12 <?php echo ($this->formElementErrors($form->get('identity'))) ? 'has-error' : '' ; ?>">
                            <div class="col-md-4">
                                <?php echo $this->formLabel($form->get('identity')) ?>
                            </div>

                            <div class="col-md-8">
                                <?php echo $this->formInput($form->get('identity')) ?>
                                <div class="col-md-12">
                                    <div class="help-block">
                                        <?php echo $this->formElementErrors($form->get('identity')); ?>
                                    </div>
                                </div>
                            </div>
                        </div>
                        <div class="form-group col-xs-12 <?php echo ($this->formElementErrors($form->get('identity'))) ? 'has-error' : '' ; ?>">
                            <div class="col-md-4">
                                <?php echo $this->formLabel($form->get('credential')) ?>
                            </div>

                            <div class="col-md-8">
                                <?php echo $this->formInput($form->get('credential')) ?>
                                <div class="col-md-12">
                                    <div class="help-block">
                                        <?php echo $this->formElementErrors($form->get('credential')); ?>
                                    </div>
                                </div>
                            </div>
                        </div>
                        <?php if ($this->redirect): ?>
                            <input type="hidden" name="redirect" value="<?php echo $this->escapeHtml($this->redirect) ?>" />
                        <?php endif ?>
                </div>
                <div class="panel-footer text-center">
                    <?php echo $this->formButton($form->get('submit')) ?>
                </div>
                <?php echo $this->form()->closeTag(); ?>
            </div>
        </div>
    </div>
</div>